<?php 
class Site extends Contorller{

	public function init(){
		$this->layout='main';
		if(!$this->isLogin){
			$this->redirect("login",'index');
		}
	}


	public function indexAction(){
		$data = 'dd';
		$date = Fw::app()->load("date");
		$fields = array('name'=>'ids','type'=>'int');
        
       // $rss = Fw::app()->load("rss_php");  //new rss_php;
     
        //$rss->load('http://news.google.com/?output=rss');

       // var_dump($rss->getItems());
    
        //echo json_encode($rss->getRSS());

		$this->render('index');
	}

	public function listAction(){
		$viewData = $this->db()->select("site",'by:site_id');
		$this->render("list",array('viewData'=>$viewData));
	}

	public function modelAction(){
		$this->layout = null;
		$this->render("modellist");
	}

	public function addsiteAction(){
		$state = array();
		$userInfo = Fw::app()->getSession('userInfo');
		if(!empty($this->request['siteName'])){
			$siatename = $this->request['siteName'];
			$value['site_name'] = $siatename;
			$value['user_id']  = $userInfo["user_id"];
			$value["createtime"] = date("Y-m-d h:i:s");
			$install = $this->db()->insert('site',$value);
			if($install){
				$state["state"] = true;
			}else{
				$state["state"] = false;
			}
		}else {
			$state["state"] = false;
		}
		echo json_encode($state);
	}

	public function deleteAction(){
		$state = array();
		if(!empty($this->request["site_id"])){
			$install = $this->db()->del('site',array('site_id'=>$this->request["site_id"]));
			if($install){
				$state["state"] = true;
			}else{
				$state["state"] = false;
			}
		}else {
			$state["state"] = false;
		}
		echo json_encode($state);
	}
}
?>